package com.prs.crm.domain.sale;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

import com.prs.crm.domain.FlowCodeEntity;
import com.prs.crm.domain.store.StoreRoom;

@Entity
@Table(name = "sale_saleshipping")
public class SalesShipping extends FlowCodeEntity {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;
	
	
	/**
	 * 销售发货主题
	 */
	
	private String salesShippingName;

	/**
	 * 关联合同
	 */
	@ManyToOne
	private SalesContract salesContract;
	
	/**
	 * 库房
	 */
	@ManyToOne
	private StoreRoom room;

	/**
	 * 发货单号
	 */
	private String shippingCode;

	/**
	 * 发货日期
	 */
	private Date shippingDate;

	/**
	 * 收款方式
	 */
	@ManyToOne
	private GatheringWay gatheringway;

	/**
	 * 发货方式
	 */
	@ManyToOne
	private ShippingWay shippingway;

	/**
	 * 发票类型
	 */
	@ManyToOne
	private InvoiceType invoiceType;

	/**
	 * 收款期限
	 */
	
	private Integer gatheringDate;
	
	
	/**
	 * 日期
	 */
	private Date dates;

	/**
	 * 到站地点
	 * 
	 */
	private String reachSite;

	/**
	 * 单位名称
	 */
	private String buySite;
	/**
	 * 联系人
	 * 
	 */
	
	private String person;

	/**
	 * 通讯地址
	 */
	private String address;

	/**
	 * 电话
	 */
	private String phone;

	/**
	 * 银行账号
	 */
	private String bankNum;

	/**
	 * 税号
	 */
	private String levyNum;

	/**
	 * 发货明细
	 */

	@OneToMany(mappedBy = "salesShipping")
	@Cascade( { org.hibernate.annotations.CascadeType.ALL,
			org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
	private Set<SalesShippingDetail> details;

	/**
	 * 发货概要
	 * 
	 */
	@Lob
	private String remark;
	/**
	 * 收款状态
	 * 0:未开始
	 * 1:开始单位完成
	 * 2：完成
	 */
	@Column(columnDefinition = "Integer(2) default '0'")
	private int receivesState;
	/**
	 * 出库状态0没有完成1完成
	 */
	@Column(columnDefinition = "Integer(2) default '0'")
	private int outState;
	/**
	 * 首款数量
	 */
	@Column(columnDefinition = "Integer(2) default '0'")
	private double receiveNumber;

	public double getReceiveNumber() {
		return receiveNumber;
	}

	public void setReceiveNumber(double receiveNumber) {
		this.receiveNumber = receiveNumber;
	}

	public int getReceivesState() {
		return receivesState;
	}

	public void setReceivesState(int receivesState) {
		this.receivesState = receivesState;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public SalesContract getSalesContract() {
		return salesContract;
	}

	public void setSalesContract(SalesContract salesContract) {
		this.salesContract = salesContract;
	}

	public String getShippingCode() {
		return shippingCode;
	}

	public void setShippingCode(String shippingCode) {
		this.shippingCode = shippingCode;
	}

	public Date getShippingDate() {
		return shippingDate;
	}

	public void setShippingDate(Date shippingDate) {
		this.shippingDate = shippingDate;
	}

	public GatheringWay getGatheringway() {
		return gatheringway;
	}

	public void setGatheringway(GatheringWay gatheringway) {
		this.gatheringway = gatheringway;
	}

	public ShippingWay getShippingway() {
		return shippingway;
	}

	public void setShippingway(ShippingWay shippingway) {
		this.shippingway = shippingway;
	}

	public InvoiceType getInvoiceType() {
		return invoiceType;
	}

	public void setInvoiceType(InvoiceType invoiceType) {
		this.invoiceType = invoiceType;
	}

	public Integer getGatheringDate() {
		return gatheringDate;
	}

	public void setGatheringDate(Integer gatheringDate) {
		this.gatheringDate = gatheringDate;
	}

	public String getReachSite() {
		return reachSite;
	}

	public void setReachSite(String reachSite) {
		this.reachSite = reachSite;
	}

	public String getBuySite() {
		return buySite;
	}

	public void setBuySite(String buySite) {
		this.buySite = buySite;
	}

	

	public String getPerson() {
		return person;
	}

	public void setPerson(String person) {
		this.person = person;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getBankNum() {
		return bankNum;
	}

	public void setBankNum(String bankNum) {
		this.bankNum = bankNum;
	}

	public String getLevyNum() {
		return levyNum;
	}

	public void setLevyNum(String levyNum) {
		this.levyNum = levyNum;
	}

	public Set<SalesShippingDetail> getDetails() {
		return details;
	}

	public void setDetails(Set<SalesShippingDetail> details) {
		this.details = details;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public Date getDates() {
		return dates;
	}

	public void setDates(Date dates) {
		this.dates = dates;
	}

	public StoreRoom getRoom() {
		return room;
	}

	public void setRoom(StoreRoom room) {
		this.room = room;
	}

	
	public String getSalesShippingName() {
		return salesShippingName;
	}

	public void setSalesShippingName(String salesShippingName) {
		this.salesShippingName = salesShippingName;
	}

	public void addDetail(SalesShippingDetail detail) {
		if (details == null)
			details = new HashSet<SalesShippingDetail>();
		detail.setSalesShipping(this);
		details.add(detail);
	}

	public int getOutState() {
		return outState;
	}

	public void setOutState(int outState) {
		this.outState = outState;
	}
}
